<?
$task_id = $_REQUEST['task_id'];
$obj = new CTask();
$obj->load($task_id);
$reasons = $obj->canComplete();
if(count($reasons)>0) {
	$AppUI->setMsg( implode('<p/>',$reasons), UI_MSG_ERROR );
	$AppUI->redirect();
}

$obj->task_is_complete = 1; // complete
$obj->task_percent_complete = 100; // complete
if (($msg = $obj->store())) {
	$AppUI->setMsg( $msg, UI_MSG_ERROR );
} else {
	$AppUI->setMsg( "Task has been completed", UI_MSG_OK, true );
}
$AppUI->redirect();

?>
